/**
 * Copyright (C), 2015-2018, XXX有限公司
 * FileName: ResponseResultHandler
 * Author:   sjkyll
 * Date:     2018-07-27 14:13
 * Description:
 * <author>          <time>          <version>          <desc>
 * 作者姓名         修改时间           版本号            描述
 */
package com.cdqidi.smsservice.handle;

import com.cdqidi.smsservice.dto.AjaxResult;
import org.springframework.core.MethodParameter;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;

import java.lang.annotation.Annotation;

/**
 * 〈一句话功能简述〉<br>
 *
 * @author sjkyll
 * @create 2018-07-27 14:13
 * @since 1.0.0
 */
@RestControllerAdvice(basePackages = "com.cdqidi.smsservice.controller.api")
public class ResponseApiHandler implements ResponseBodyAdvice<Object> {
    @Override
    public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) {
        return true;
    }

    @Override
    public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
        return AjaxResult.success(body);
    }
}